<?php
/**
 *
 *
 * @author Zeon <scplay@gmail.com>
 * @date 2018/6/29 8:52
 * @copyright PanxSoft Inc.
 */

namespace Tests\Concerns;

use Laravel\Dusk\Browser;
use Laravel\Dusk\Concerns\ProvidesBrowser;

/**
 * Trait BrowserResize
 *
 * @mixin ProvidesBrowser
 * @package Tests\Concerns
 */
trait ResizeBrowser
{
    /**
     * @param \Closure $callback
     * @throws \Throwable
     */
    protected function fullHDBrowser(\Closure $callback)
    {
        $this->browse(function (Browser $browser) use ($callback) {
            $browser->resize(1920, 1080);
            $callback($browser);
        });
    }
    
    /**
     * @param \Closure $callback
     * @throws \Throwable
     */
    protected function fullScreenBrowser(\Closure $callback)
    {
        $this->browse(function (Browser $browser) use ($callback) {
            $browser->maximize();
            $callback($browser);
        });
    }
    
    /**
     * @param \Closure $callback
     * @throws \Throwable
     */
    protected function iPhoneBrowser(\Closure $callback)
    {
        $this->browse(function (Browser $browser) use ($callback) {
            $browser->resize(375, 667);
            $callback($browser);
        });
    }
    
    /**
     * @param \Closure $callback
     * @throws \Throwable
     */
    protected function iPadBrowser(\Closure $callback)
    {
        $this->browse(function (Browser $browser) use ($callback) {
            $browser->resize(768, 1024);
            $callback($browser);
        });
    }

}